import React, { useEffect } from 'react';
import { Form, Input, Button } from 'antd';
import { SearchInput } from '@/components/UserForm';
import { getPostType } from '@/services/setting/recruitManage';

const SearchForm = ({ form, onSearch }) => {
    const { getFieldDecorator } = form;

    const handleSubmit = e => {
        e.preventDefault();
        onSearch();
    };
    useEffect(() => {}, []);
    return (
        <Form layout="inline" onSubmit={handleSubmit} style={{ display: 'inline-block' }}>
            <Form.Item>
                {getFieldDecorator(
                    'postName',
                    {}
                )(<Input placeholder="输入关键词搜索更多职位" style={{ width: 260 }} />)}
            </Form.Item>
            <Form.Item>
                {getFieldDecorator(
                    'postType',
                    {}
                )(
                    <SearchInput
                        getData={params =>
                            getPostType(params).then(res => {
                                if (res && res.code === 10000 && res.data) {
                                    return res.data || [];
                                }
                                return [];
                            })
                        }
                        fieldsName={{
                            value: 'value',
                            title: 'name'
                        }}
                        selectProps={{
                            placeholder: '请选择职位类型',
                            style: { width: 200 },
                            mode: 'multiple',
                            maxTagCount: 3
                        }}
                    />
                )}
            </Form.Item>
            <Form.Item>
                {getFieldDecorator(
                    'workPlace',
                    {}
                )(
                    <SearchInput
                        getData={() => {
                            const arr = [
                                {
                                    title: '厦门',
                                    value: '0'
                                },
                                {
                                    title: '新加坡',
                                    value: '1'
                                }
                            ];
                            return arr;
                        }}
                        fieldsName={{
                            value: 'value',
                            title: 'title'
                        }}
                        selectProps={{
                            placeholder: '请选择工作地点',
                            style: { width: 200 },
                            mode: 'multiple',
                            maxTagCount: 3
                        }}
                    />
                )}
            </Form.Item>
            <Form.Item>
                <Button type="primary" htmlType="submit">
                    搜索
                </Button>
            </Form.Item>
        </Form>
    );
};
export default SearchForm;
